/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.gis.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author ZhuangBing Yan
* @date 2022-08-15
**/
@Entity
@Data
@Table(name="gis_feed_history")
public class FeedHistory extends BaseEntity implements Serializable  {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "主键ＩＤ")
    private Long id;
//
//    @ApiModelProperty(value = "路线")
//    @OneToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name="id",referencedColumnName="id")
//    private TimeLine timeLine;


    @Column(name = "`car_number`")
    @ApiModelProperty(value = "车牌号")
    private String carNumber;

    @Column(name = "`card_number`")
    @ApiModelProperty(value = "卡号")
    private String cardNumber;

    @Column(name = "`good_name`")
    @ApiModelProperty(value = "货物名称")
    private String goodName;

    @Column(name = "`deliver_company`")
    @ApiModelProperty(value = "发货单位")
    private String deliverCompany;

    @Column(name = "`area`")
    @ApiModelProperty(value = "区域")
    private String area;

    @Column(name = "`feed_company`")
    @ApiModelProperty(value = "运输单位")
    private String feedCompany;

    @Column(name = "`dispose_company`")
    @ApiModelProperty(value = "处置单位")
    private String disposeCompany;

    @Column(name = "`gross_weight`")
    @ApiModelProperty(value = "毛重（吨）")
    private BigDecimal grossWeight;

    @Column(name = "`tare_weight`")
    @ApiModelProperty(value = "皮重(吨)")
    private BigDecimal tareWeight;

    @Column(name = "`deduction_weight`")
    @ApiModelProperty(value = "扣减(吨)")
    private BigDecimal deductionWeight;

    @Column(name = "`net_weight`")
    @ApiModelProperty(value = "净重(吨)")
    private BigDecimal netWeight;

    @Column(name = "`create_by`")
    @ApiModelProperty(value = "出单人(创建人)")
    private String createBy;

    @Column(name = "`work_shop_name`")
    @ApiModelProperty(value = "车间名称")
    private String workShopName;

    @Column(name = "`type`")
    @ApiModelProperty(value = "数据类型()")
    private Integer type;

    @Column(name = "`status`")
    @ApiModelProperty(value = "数据状态")
    private Integer status;

    @Column(name = "`is_del`")
    @ApiModelProperty(value = "是否删除( 0 未删除  1 已删除)")
    private Boolean isDel;

    @Column(name = "`enter_in_time`")
    @ApiModelProperty(value = "进厂时间")
    private Timestamp enterInTime;

    @Column(name = "`position_start_lat`")
    @ApiModelProperty(value = "起点经度坐标")
    private BigDecimal positionStartLat;

    @Column(name = "`position_start_lng`")
    @ApiModelProperty(value = "起点纬度坐标")
    private BigDecimal positionStartLng;


    @Column(name = "`line_position`")
    @ApiModelProperty(value = "路经线坐标")
    private String linePosition;

    @Column(name = "`position_end_lat`")
    @ApiModelProperty(value = "终点经度坐标")
    private BigDecimal positionEndLat;

    @Column(name = "`position_end_lng`")
    @ApiModelProperty(value = "终点纬度坐标")
    private BigDecimal positionEndLng;

    /**
     *
     * @return 起点经纬度
     */
    public String getOrigin(){
        return this.positionStartLng+","+this.positionStartLat;
    }

    /**
     *
     * @return 目的地经纬度
     */
    public String getDestination(){
        return this.positionEndLng+","+this.positionEndLat;
    }

    public void copy(FeedHistory source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
